﻿using System.Collections.Generic;
using Best.SmartCms.Dto.Response;
using Best.SmartCms.Dto;
using Best.SmartCms.Dto.Common;
using Best.SmartCms.Service;
using Microsoft.AspNetCore.Mvc;

namespace Best.SmartCms.API.Controllers
{
    /// <summary>
    /// ChannelGroup
    /// </summary>
    public class ChannelGroupController : Controller
    {
        private readonly ChannelGroupService _channelGroupService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="channelGroupService"></param>
        public ChannelGroupController(ChannelGroupService channelGroupService)
        {
            _channelGroupService = channelGroupService;
        }


        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("channelgroup/pagelist")]
        public PagedResponse<ChannelGroupListDto> PageList([FromBody]ChannelGroupListQueryDto query)
        {
            var ret = _channelGroupService.PageList(query);
            return ret;
        }


        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("channelgroup/create")]
        public ApiResponse Create([FromBody]ChannelGroupEditDto dto)
        {
             _channelGroupService.Create(dto);
            return ApiResponse.Succeeds();
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("channelgroup/edit")]
        public ApiResponse Edit([FromBody]ChannelGroupEditDto dto)
        {
            _channelGroupService.Edit(dto);
            return ApiResponse.Succeeds();
        }


        /// <summary>
        /// 详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        [Route("channelgroup/Info")]
        public ApiResponse<ChannelGroupEditDto> Info(long id)
        {
            var ret = _channelGroupService.Info(id);
            return ApiResponse<ChannelGroupEditDto>.Succeeds(ret);
        }


        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        [Route("channelgroup/delete")]
        public ApiResponse Delete(long id)
        {
            _channelGroupService.Delete(id);
            return ApiResponse.Succeeds();
        }

        /// <summary>
        /// 选择
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Route("channelgroup/Option")]
        public ApiResponse<List<SelectOptionDto>> Option()
        {
            var list = _channelGroupService.Option();
            return ApiResponse<List<SelectOptionDto>>.Succeeds(list);
        }
    }
}